package com.chinaunicom.create.prototype.deepcopy;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2022/7/19 14:15
 * Description:
 */
public class DCClient {

    public static void main(String[] args) {
        try {
            Person person = new Person();
            person.setName("张三");
            person.setTel("13289316602");
            person.setEmail("13289316602@163.com");
            person.setAge(18);

            DDept dept = new DDept();
            dept.setDeptName("软件开发");
            dept.setType("1");
            dept.setDeptAdd("陕西西安");
            person.setDept(dept);

            Person clonePerson = (Person) person.clone();
            System.out.println("person: " + person.toString());
            System.out.println("clone person: " + person.toString());

            System.out.println("对象hashCode: " + person.hashCode() + "-----: " + clonePerson.hashCode());
            System.out.println("非基本类型hashCode: " + person.getDept().hashCode() + "-----: " + clonePerson.getDept().hashCode());
            System.out.println("基本类型String hashCode: " + person.getTel().hashCode() + "-----: " + clonePerson.getTel().hashCode());
            System.out.println("基本类型int hashCode: " + person.getAge() + "-----: " + clonePerson.getAge());

            System.out.println("---------------------------");
            
            person.setName("李四");
            DDept newDept = new DDept();
            newDept.setDeptName("云平台开发");
            newDept.setType("2");
            newDept.setDeptAdd("陕西西安");
            person.setDept(newDept);

            System.out.println("person: " + person.toString());
            System.out.println("clone person: " + clonePerson.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
